﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using System.Net;
using System.IO;
using System.Text;

namespace Tasks.UI.Controllers
{
    public class WordActionResult : ActionResult
    {
        private string _htm;
        public string htm
        {
            get { return _htm; }
        }

        private string _filename;
        public string fileName
        {
            get { return _filename; }
        }
        public WordActionResult(string phtm, string pFileName)
        {
            _htm = phtm;
            _filename = pFileName;

        }
        public override void ExecuteResult(ControllerContext context)
        {

            string html = _htm;
            HttpContext curContext = HttpContext.Current;
            curContext.Response.Clear();
            curContext.Response.AddHeader("content-disposition", "attachment;filename=" + _filename);
            curContext.Response.Charset = "utf-8";
            curContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            curContext.Response.ContentType = "application/ms-word";
            curContext.Response.Write(html);
            curContext.Response.End();
        }


    }
}
